$(function () {
    var ex_datagrid = $("#ex_datagrid");

    ex_datagrid.datagrid({
        toolbar: "#tb",
        fit: true,
        url: "/exchangeGift/list",
        fitColumns: true,
        singleSelect: true,
        striped: true,
        pagination: true,
        columns: [[
            {field: "id", hidden: true},
            {field: "memberinfoCardno", title: "会员卡号", width: 50, align: "center"},
            {field: "memberinfoName", title: "会员姓名", width: 50, align: "center"},
            {field: "giftName", title: "礼品名称", width: 50, align: "center"},
            {field: "number", title: "兑换数量", width: 50, align: "center"},
            {
                field: "giftIntegral", title: "消费积分", width: 50, align: "center", formatter: function (value) {
                return "<font color='red'>" + value + "</font>"
            }
            },
            {field: "inputuserUsername", title: "操作人员", width: 50, align: "center"},
            {field: "exchangedate", title: "兑换时间", width: 50, align: "center", sortable: true, order: "desc"}
        ]]
    })

    //同一管理响应函数
    var cmdObj = {
        //刷新
        reload: function () {
            ex_datagrid.datagrid("reload");
        },
        query: function () {
            //获取查询参数
            var kw = $("#keyword").textbox("getValue");
            //表格加载时顺带一起传递查询参数
            ex_datagrid.datagrid("load", {
                keyword: kw
            });
        },
        export: function () {
            window.location.href="/exchangeGift/export";
        }

    }


//调用cmdObj
    $("a[data-cmd]").click(function () {
        var cmd = $(this).data('cmd');
        cmdObj[cmd]();
    })
})

